-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-130168: pyrepl can messup and poll is not thread safe #138617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Misc/NEWS.d/next/Library/2025-09-07-19-47-35.gh-issue-130168.qvtlOZ.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Bénédikt Tran <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Hum, now tests fail but I don't know why. Is there another place where we use the internal state? |
same like #124030 |
Yeah but https://github.com/python/cpython/actions/runs/17528155338/job/49781429653?pr=138617 worked and it was before my suggestions. Ok, remove the |
Signed-off-by: yihong0618 <[email protected]>
Done will check the test |
Mmh, so apparently the issue is indeed with the cleanup. Though I don't understand why.... because cleanups are called in LIFO. |
When I meant "remove it", I meant remove the addCleanup, but keep |
Signed-off-by: yihong0618 <[email protected]>
sorry for forget that, now move it back |
do we need to open an issue to track this? |
This patch also make #129614 the same behavior as 3.12 |
Maybe, but I'll need to check with a smaller reproducer. |
@picnixz after some dig found why here the issue is that we mock the
it is fine but in some system like ubuntu arm 24 but this length is 20
you can use this script to check import sys
import termios
sys.path.insert(0, "./Lib")
from _pyrepl.fancy_termios import tcgetattr, tcsetattr
def main():
try:
state = tcgetattr(0)
print("Real tcgetattr works, cc length:", len(state.cc))
tcsetattr(0, termios.TCSADRAIN, state)
print("Real tcsetattr works")
except Exception as e:
print("Error:", e)
if __name__ == "__main__":
main() if we use self.addclean ... it calls the patch and the length is different
so I think we add console.restore() in the last is fine |
merge and fix the conflict |
interesting fail will try to figure out why fixed |
Signed-off-by: yihong0618 <[email protected]>
I understand this is to be in sync what the old REPL showed, but isn't that misleading, because here |
It is, through
Mmh, then the fix should be different probably. The OP's output seems to be on darwin which is Unix-based as well. Note that In addition, on Apple terminals, line wrap is disabled so maybe something is different here as well? |
Just FTR, confirming that Windows isn't affected (since as said like on Linux no Legacy console: The prompt is overridden in this case, but this will be solved by #138732. |
Oh, I know :) I was referring to
Why not just fail with "concurrent poll" - why mimic the 3.12 error message here? |
sorry for the confusion next time will try to use LLM or something else to make a better desc. |
yes it is mess up |
Signed-off-by: yihong0618 <[email protected]>
@chris-eibl now fixed the mess up can you help to check? |
Works now for me on native Ubuntu 24.04.3 LTS. |
thank you for confirm the reason is that merge conflict~ |
Still unsure about the IMHO the PR would be simpler without trying to mimic it, but that's the the pyrepl maintainers decision, anyway. |
the reason I choose that is make the runtime error message as basic repl |
# Forbid re-entrant calls and use the old REPL error message. | ||
raise RuntimeError("can't re-enter readline") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe we can change the message. I don't have a suggestion now but I'd like REPL maintainers to first check this PR.
This fix issue 130168
but for this one it contains two issues:
the first one is for poll here is not thread safe
more can check. ##53111
and the second one is for the prepare and restore the error message will mess up.
and for the default pyrepl >= 3.13 the input is wrote in python different from the old one
this patch make the error same which is
can't re-enter readline
like python3.12before this patch:
after this patch:

which not mess up anything
cc @gaogaotiantian can you help to check?
Thank you very much.